package com.yunshang.shoppingmall.Methods;

import com.yunshang.shoppingmall.entity.Order;
import com.yunshang.shoppingmall.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Component
public class OrderMethods {
    @Autowired
    private OrderService orderService;
    private static OrderService orderService1;

    private static List<String> orderNoList = new ArrayList();

    @PostConstruct
    public void init() {
        orderService1 = orderService;
    }

    public static List<String> getOrderNoList(Date t1,Date t2) {
        if(orderNoList==null || orderNoList.size()==0) {
            List<Order> orderNoList1 = orderService1.selectDate(t1,t2);

            for(int i=0;i<orderNoList1.size();i++)
            {
                //System.out.println(userNoList1.get(i).getUserNo());
                orderNoList.add(orderNoList1.get(i).getOrderNo());
            }
        }
        return orderNoList;
    }
    /*
    public static UserNo getUserNo(String userNo) {
        List<UserNo> userNoList1 = userNoService1.selectUserNoList1(userNo);
        if (userNoList1 != null && userNoList1.size() == 1) {
            return userNoList1.get(0);
        }
        return null;
    }

    //插入数据
    public static int insert(UserNo userNo)
    {
        return userNoService1.insert(userNo);
    }
    */
}
